<?php


namespace App\Http\Server;


use App\Models\Manufacturer;
use App\Services\QueryService;

class ManufacturerServer
{

    public function addManufacturerServer($id,$manufacturer_name,$manufacturer_address,$manufacturer_phone){
        if(isset($id) && !empty($id)){
            $model = Manufacturer::find($id);
        }else{
            $model = new Manufacturer();
        }
        $model->manufacturer_name = $manufacturer_name;
        $model->manufacturer_address = $manufacturer_address;
        $model->manufacturer_phone = $manufacturer_phone;
        $model->save();
        $customer = Manufacturer::where('manufacturer_phone',$manufacturer_phone)->first();
        return ['status'=>200,'data'=>$customer,'msg'=>'success'];
    }

    /**
     * 获取客户列表
     * @param $customer_name
     * @param $customer_phone
     */
    public function getManufacturerListServer($params,$per_page=10)
    {
        // 执行查询
        $data = Manufacturer::Search($params)->paginate($per_page);

        return ['status'=>200,'data'=>$data,'msg'=>'success'];
    }
}
